﻿using UnityEngine;
using TinyWnd;

public class SkillWnd : Wnd
{
    TweenAlpha twAlpha;
    GameObject btnGo;

    protected override void OnAwake()
    {
        _wndId = WndId.skill;
        _wndType = WndType.normal;
        _unifiedClose = true;
        _colliderMode = WndColliderMode.transparent;

        var tran = transform;
        twAlpha = Utility.FindChild<TweenAlpha>(tran, "Bg");
        btnGo = Utility.FindChild(tran, "Bg/BtnGoLevel").gameObject;

        UIEventListener.Get(btnGo).onClick = delegate
        {
            WndMgr.inst.ShowWindow(WndId.level);
        };
    }

    protected override void OnShow(WndContentData content)
    {
        gameObject.SetActive(true);
        twAlpha.onFinished.Clear();
        twAlpha.PlayForward();
    }

    protected override void OnHide()
    {
        twAlpha.SetOnFinished(CbFinishClose);
        twAlpha.PlayReverse();
    }

    void CbFinishClose()
    {
        gameObject.SetActive(false);
    }
}
